package com.gupao.strategy;

/**
 * 定义具体的环境角色 Created by ktyan on 2017/5/23.
 */
public class Context
{
    // 持有Strategy接口的引用
    private Strategy strategy;

    /**
     * 实例化Strategy对象，传子类
     * @param strategy
     */
    public Context(Strategy strategy)
    {
        super();
        this.strategy = strategy;
    }
    
    public Strategy getStrategy()
    {
        return strategy;
    }
    
    public void setStrategy(Strategy strategy)
    {
        this.strategy = strategy;
    }

    /**
     * 在Context完成计算动作
     * @param a
     * @param b
     * @return
     */
    public int calculate(int a, int b)
    {
        return strategy.calculate(a, b);
    }
    
}
